package com.action;

import org.apache.struts.action.ActionForward;

import admin.mode.AdminMode;
import admin.mode.MemberDispatchAction;
import base.Power;

public class LoginAction extends MemberDispatchAction {
	public ActionForward user_login(Power power, AdminMode admin)
			throws Exception {

		// String furl = power.getParameter("furl");
		int loginFlag = admin.login();
		if (loginFlag == AdminMode.LOGIN_SUCCESS) {

			return power.findForward("/PublicAction.do?opt=getValue", true);
		} else {
			power.setAttribute("message", getMessage(loginFlag));
			return power.findForward("/login.jsp", false);
		}
	}

	public String getMessage(int i) throws Exception {
		String message = "";
		switch (i) {
		case 1:
			message = "用户名错误";
			break;
		case 2:
			message = "密码错误";
			break;
		case 3:
			message = "登录成功";
			break;
		default:
			message = "登录失败";
		}
		return message;
	}
}
